import { app } from "../../../../app-core/App";
import { injectable } from "../../../../app-core/inject";
import { Facade } from "../../../../app-core/mvcs/Facade";
import { LoginModel } from "../model/LoginModel";

@injectable('LoginFacade2')
export class LoginFacade extends Facade {
    public mapModel() {
        this.injector.mapSingleton('LoginModel', LoginModel);
    }

    public mapMediator() {
        this.viewMap.mapViewCreator('login_scene_creator', async () => {
            let scene = await app.res.loadSceneAsync('app-login');
            return scene;
        });

        this.injector.mapValue('login_scene', 'app-login');
        this.mediatorMap.mapView('login_scene', 'LoginSceneMediator');

        this.viewMap.mapViewRes('login_view', 'ui/login/login2');
        this.mediatorMap.mapView('login_view', 'LoginMediator');

    }

    public mapCommands() {
        this.commandMap.mapCommand('LoginCommand');
    }

    openLoginView() {
        this.dispatch('Evt_Switch_View', 'login_view');
    }
}